package com.animal.controller;

import com.animal.entity.pojo.AGoodsy;
import com.animal.service.GoodsyService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("goodsy")
public class GoodsyController {

    @Resource
    private GoodsyService goodsyService;

    @RequestMapping("/getAGoodsyAll")
    public String getAGoodsyAll(Model model) {
        List<AGoodsy> list = goodsyService.getAGoodsyAll();
        if (list != null) {
            model.addAttribute("aglist", list);
            return "goods";
        } else {
            return "error";
        }
    }

    @RequestMapping("/updateAGoodsy")
    public String updateAGoodsy(@RequestParam("goodsyid") Integer goodsyid,
                                @RequestParam("salvageamount") Integer salvageamount) {
        boolean flag = goodsyService.updateSalvageamountById(goodsyid, salvageamount);
        if (flag) {
            return "redirect:/goodsy/getAGoodsyAll";
        } else {
            return "error";
        }
    }
}
